﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using CommonEntity.CommonImageEntities;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using ScienceAppService.ModuleInterface;

namespace ScienceAIApp.ViewModels.SubViewModels;

public class PatientSeriesViewModel : ScienceBaseViewModel
{
    private IImageShowService _imageShowService;
    private IMarkDrawService _markDrawService;
    public SplitSeriesInfo CurrentSeries { get; set; }

    [Reactive] public string ShowDescription { get; set; }
    [Reactive] public bool IsChecked { get; set; }

    /// <summary>
    /// 出现删除图标
    /// </summary>
    [Reactive] public bool IsHistory { get; set; }

    public ReactiveCommand<Unit, Unit> ChooseSeriesCommand;

    public ReactiveCommand<Unit, Unit> DeleteSeriesCommand;
    
    public PatientSeriesViewModel(IImageShowService imageShowService, IMarkDrawService markDrawService)
    {
        _imageShowService = imageShowService;
        _markDrawService = markDrawService;

        ChooseSeriesCommand = ReactiveCommand.CreateFromTask(async () =>
        {
            await _imageShowService.SetImageFile(CurrentSeries);
            _markDrawService.ClearData();
        });

        DeleteSeriesCommand = ReactiveCommand.CreateFromTask(async () =>
        {
            //await _imageShowService.DeleteSeries(CurrentSeries);
        });

    }

    //[Reactive] public string PatientName { get; set; }
    //[Reactive] public string SeriesDescription { get; set; }
    //[ObservableAsProperty]
    //public string ShowDescription { get; set; }

    //this.WhenAnyValue(x => x.PatientName, y=> y.SeriesDescription)
    //    .Select(p => $"{p.Item1} - {p.Item2}")
    //    .ToPropertyEx(this, model => model.ShowDescription);
}

